import { userAccountLogin } from '@/api/user'

// 用户状态
export default {
  namespaced: true,
  state: () => ({
    profile: {
      id: '',
      avatar: '',
      nickname: '',
      account: '',
      mobile: '',
      token: ''
    }
  }),
  mutations: {
    setProfile (state, profile) {
      state.profile = profile
    },
    delProfile (state) {
      state.profile = {
        id: '',
        avatar: '',
        nickname: '',
        account: '',
        mobile: '',
        token: ''
      }
    }
  },
  actions: {
    async getProfile ({ commit }, payload) {
      const { result } = await userAccountLogin(payload)
      // console.log(result)
      commit('setProfile', result)
    }
  }
}
